﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using CRM.Entity;

using CRM.BLL;
using DP.Web.UI.Controls;
using DP.Web.UI;
using DP.Common;
using DP.Data.OracleClient;
using System.Data;

namespace CRM.Web.ClaimFormManage
{
    public partial class List : Common.PageBase
    {

        public string ModifyUrl = "Modify.aspx?CLAIMFORMID={0}";
        T_CLAIMFORM_BLL bll = new T_CLAIMFORM_BLL();
        private T_CLAIMFORMRESULT_BLL claimFormResultBll = new T_CLAIMFORMRESULT_BLL();
        T_DICTIONARY_BLL dBll = new T_DICTIONARY_BLL();
        private T_CONTENTAUTHORITY_BLL caBll = new T_CONTENTAUTHORITY_BLL();
        private OracleDAL<NZ_TCLAIMCARD_Entity> _nzclaimform = new OracleDAL<NZ_TCLAIMCARD_Entity>();
        private OracleDAL<WJJ_TCLAIMCARD_Entity> _wjjclaimform = new OracleDAL<WJJ_TCLAIMCARD_Entity>();
        private OracleDAL<ZZJ_TCLAIMCARD_Entity> _zzjclaimform = new OracleDAL<ZZJ_TCLAIMCARD_Entity>();
        private OracleDAL<QC_TCLAIMCARD_Entity> _qcclaimform = new OracleDAL<QC_TCLAIMCARD_Entity>();
        private OracleDAL<MT_TCLAIMCARD_Entity> _mtclaimform = new OracleDAL<MT_TCLAIMCARD_Entity>();
        //SqlServerDAL<T_CLAIMFORM_Entity> dal = new SqlServerDAL<T_CLAIMFORM_Entity>();

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            if (PageHelper.GetQueryString(this.Page, "SearchType") == "VehicleAssociate")
            {
                phSearch.Visible = false;
                gvList.PageSize = 10;
            }
            else
            {
                gvList.PageSize = 100;
            }
            PageHelper.SetPrePageUrl(this.Page);
            PageHelper.SetPopCalender(this.Page, txtFEEDBACKDATEBegin);
            PageHelper.SetPopCalender(this.Page, txtFEEDBACKDATEEnd);
            PageHelper.SetPopCalender(this.Page, txtCREATETIMEBegin);
            PageHelper.SetPopCalender(this.Page, txtCREATETIMEEnd);

        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                lblExportMaxRows.Text = configBll.GetCacheValueByName(this.Page, "ExportMaxRows");
                txtRecordBegin.Text = StaticConstant.RecordBegin;
                txtRecordEnd.Text = StaticConstant.RecordEnd;

                ddlISFEEDBACKBinding();
                ddlSTATUSBinding();
                ddlSPTYPEBinding();
                ddlPRODUCTSATISFACTIONBinding();
                ddlSERVICESATISFACTIONBinding();
                ddlSERVICECARDTYPENAMEBinding();

                GetUrlQueryToControl();
                gvDataBinding();
            }
        }


        #region 页面初始化数据绑定


        /// <summary>
        /// DDLs the SERVICESATISFACTION binding.
        /// </summary>
        private void ddlSERVICESATISFACTIONBinding()
        {
            ddlSERVICESATISFACTION.DataSource = dBll.GetCacheListByType(this.Page, DictionaryType.GetNameByKey("ClaimFormServiceSatisfaction"));
            ddlSERVICESATISFACTION.DataTextField = "DictValue";
            ddlSERVICESATISFACTION.DataValueField = "DictKey";
            ddlSERVICESATISFACTION.DataBind();
            ddlSERVICESATISFACTION.Items.Insert(0, new ListItem("",""));

        }

        /// <summary>
        /// DDLs the PRODUCTSATISFACTION binding.
        /// </summary>
        private void ddlPRODUCTSATISFACTIONBinding()
        {
            ddlPRODUCTSATISFACTION.DataSource = dBll.GetCacheListByType(this.Page, DictionaryType.GetNameByKey("ClaimFormProductSatisfaction"));
            ddlPRODUCTSATISFACTION.DataTextField = "DictValue";
            ddlPRODUCTSATISFACTION.DataValueField = "DictKey";
            ddlPRODUCTSATISFACTION.DataBind();
            ddlPRODUCTSATISFACTION.Items.Insert(0, new ListItem("",""));
        }

        /// <summary>
        /// DDLs the SPTYPE binding.
        /// </summary>
        private void ddlSERVICECARDTYPENAMEBinding()
        {
            ddlSERVICECARDTYPENAME.DataSource = dBll.GetCacheListByType(this.Page, DictionaryType.GetNameByKey("ClaimFormServiceCardType"));
            ddlSERVICECARDTYPENAME.DataTextField = "DictValue";
            ddlSERVICECARDTYPENAME.DataValueField = "DictKey";
            ddlSERVICECARDTYPENAME.DataBind();
            ddlSERVICECARDTYPENAME.Items.Insert(0, new ListItem("", ""));
        }
        /// <summary>
        /// DDLs the SPTYPE binding.
        /// </summary>
        private void ddlSPTYPEBinding()
        {
            //ddlSPTYPE.DataSource = dBll.GetCacheListByType(this.Page, DictionaryType.GetNameByKey("ClaimFormSPType"));
            //ddlSPTYPE.DataTextField = "DictValue";
            //ddlSPTYPE.DataValueField = "DictKey";
            //ddlSPTYPE.DataBind();
            //ddlSPTYPE.Items.Insert(0, new ListItem("", ""));
        }

        /// <summary>
        /// DDLs the STATUS binding.
        /// </summary>
        private void ddlSTATUSBinding()
        {
            ddlSTATUS.Items.Clear();
            EnumHelper.FillListControl(ddlSTATUS, typeof(ClaimStatus));
            ddlSTATUS.Items.Insert(0, new ListItem("", ""));
        }

        private  void ddlISFEEDBACKBinding()
        {
            ddlISFEEDBACK.Items.Clear();
            EnumHelper.FillListControl(ddlISFEEDBACK, typeof(IsFeedBack));
            ddlISFEEDBACK.Items.Insert(0, new ListItem("", ""));
            //ddlISFEEDBACK.SelectedValue = "0";

        }














        #endregion

        /// <summary>
        /// 获取 URL 上的参数存入当页面 控件中。
        /// </summary>
        private void GetUrlQueryToControl()
        {
            PageHelper.GetUrlQueryToControl(this.Page);
        }

        /// <summary>
        /// 生成查询条件字符串
        /// </summary>
        private StringBuilder GenerationSQLString()
        {
            StringBuilder sql = new StringBuilder();
            if (!String.IsNullOrEmpty(Request.QueryString["CLAIMFORMID"]))
            {
                sql.Append(" and CLAIMFORMID like '%" + Request.QueryString["CLAIMFORMID"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CASEID"]))
            {
                sql.Append(" and CASEID = '" + Request.QueryString["CASEID"] + "'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["OBJID"]))
            {
                sql.Append(" and OBJID = '" + Request.QueryString["OBJID"] + "'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CODE"]))
            {
                sql.Append(" and CODE like '%" + Request.QueryString["CODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CORPCODE"]))
            {
                sql.Append(" and CORPCODE like '%" + Request.QueryString["CORPCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CORPNAME"]))
            {
                sql.Append(" and CORPNAME like '%" + Request.QueryString["CORPNAME"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["STATUS"]))
            {
                sql.Append(" and STATUS = '" + Request.QueryString["STATUS"] + "'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CREATETIMEBegin"]))
            {
                sql.Append(" and " + bll._dal.GetBeginDateString("CREATETIME", Request.QueryString["CREATETIMEBegin"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CREATETIMEEnd"]))
            {
                sql.Append(" and " + bll._dal.GetEndDateString("CREATETIME", Request.QueryString["CREATETIMEEnd"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CREATEPEOPLEID"]))
            {
                sql.Append(" and CREATEPEOPLEID = '" + Request.QueryString["CREATEPEOPLEID"] + "'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CREATEPEOPLE"]))
            {
                sql.Append(" and CREATEPEOPLE like '%" + Request.QueryString["CREATEPEOPLE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["LASTMODIFYPEOPLEID"]))
            {
                sql.Append(" and LASTMODIFYPEOPLEID = '" + Request.QueryString["LASTMODIFYPEOPLEID"] + "'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["LASTMODIFYPEOPLE"]))
            {
                sql.Append(" and LASTMODIFYPEOPLE like '%" + Request.QueryString["LASTMODIFYPEOPLE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["LASTMODIFYTIMEBegin"]))
            {
                sql.Append(" and " + bll._dal.GetBeginDateString("LASTMODIFYTIME", Request.QueryString["LASTMODIFYTIMEBegin"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["LASTMODIFYTIMEEnd"]))
            {
                sql.Append(" and " + bll._dal.GetEndDateString("LASTMODIFYTIME", Request.QueryString["LASTMODIFYTIMEEnd"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["REMARK"]))
            {
                sql.Append(" and REMARK like '%" + Request.QueryString["REMARK"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["BRANDCODE"]))
            {
                sql.Append(" and BRANDCODE like '%" + Request.QueryString["BRANDCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["BRANDNAME"]))
            {
                sql.Append(" and BRANDNAME like '%" + Request.QueryString["BRANDNAME"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["VINCODE"]))
            {
                sql.Append(" and VINCODE like '%" + Request.QueryString["VINCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CUSTOMERID"]))
            {
                sql.Append(" and CUSTOMERID = '" + Request.QueryString["CUSTOMERID"] + "'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CUSTOMERCODE"]))
            {
                sql.Append(" and CUSTOMERCODE like '%" + Request.QueryString["CUSTOMERCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CUSTOMERNAME"]))
            {
                sql.Append(" and CUSTOMERNAME like '%" + Request.QueryString["CUSTOMERNAME"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CUSTOMERTEL"]))
            {
                sql.Append(" and CUSTOMERTEL like '%" + Request.QueryString["CUSTOMERTEL"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["MOBILEPHONE"]))
            {
                sql.Append(" and MOBILEPHONE like '%" + Request.QueryString["MOBILEPHONE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["HOMEPHONE"]))
            {
                sql.Append(" and HOMEPHONE like '%" + Request.QueryString["HOMEPHONE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["DUTYCORPCODE"]))
            {
                sql.Append(" and DUTYCORPCODE like '%" + Request.QueryString["DUTYCORPCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["DUTYCORPNAME"]))
            {
                sql.Append(" and DUTYCORPNAME like '%" + Request.QueryString["DUTYCORPNAME"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CAUSEMATERIALNAME"]))
            {
                sql.Append(" and CAUSEMATERIALNAME like '%" + Request.QueryString["CAUSEMATERIALNAME"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CAUSEMATERIALCODE"]))
            {
                sql.Append(" and CAUSEMATERIALCODE like '%" + Request.QueryString["CAUSEMATERIALCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["EXAMIDEA"]))
            {
                sql.Append(" and EXAMIDEA like '%" + Request.QueryString["EXAMIDEA"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["OTHERCLAIM"]))
            {
                sql.Append(" and OTHERCLAIM like '%" + Request.QueryString["OTHERCLAIM"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["OTHERCLAIMREASON"]))
            {
                sql.Append(" and OTHERCLAIMREASON like '%" + Request.QueryString["OTHERCLAIMREASON"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["OTHERSPAREPRICE"]))
            {
                sql.Append(" and OTHERSPAREPRICE like '%" + Request.QueryString["OTHERSPAREPRICE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["WORKFEE"]))
            {
                sql.Append(" and WORKFEE like '%" + Request.QueryString["WORKFEE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["MATFEE"]))
            {
                sql.Append(" and MATFEE like '%" + Request.QueryString["MATFEE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["OUTFEE"]))
            {
                sql.Append(" and OUTFEE like '%" + Request.QueryString["OUTFEE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["TOTALFEE"]))
            {
                sql.Append(" and TOTALFEE like '%" + Request.QueryString["TOTALFEE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["MANAGEFEE"]))
            {
                sql.Append(" and MANAGEFEE like '%" + Request.QueryString["MANAGEFEE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["JUDGERESULT"]))
            {
                sql.Append(" and JUDGERESULT like '%" + Request.QueryString["JUDGERESULT"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["APPLYREPORTID"]))
            {
                sql.Append(" and APPLYREPORTID = '" + Request.QueryString["APPLYREPORTID"] + "'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["APPLYREPORTCODE"]))
            {
                sql.Append(" and APPLYREPORTCODE like '%" + Request.QueryString["APPLYREPORTCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["APPLYREPORTTYPE"]))
            {
                sql.Append(" and APPLYREPORTTYPE like '%" + Request.QueryString["APPLYREPORTTYPE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["ORIGINALTOTALFEE"]))
            {
                sql.Append(" and ORIGINALTOTALFEE like '%" + Request.QueryString["ORIGINALTOTALFEE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SPTYPE"]))
            {
                sql.Append(" and SPTYPE like '%" + Request.QueryString["SPTYPE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["ISREPEATREPAIR"]))
            {
                sql.Append(" and ISREPEATREPAIR like '%" + Request.QueryString["ISREPEATREPAIR"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["BUSINESSDIVISIONID"]))
            {
                sql.Append(" and BUSINESSDIVISIONID = '" + Request.QueryString["BUSINESSDIVISIONID"] + "'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["BUSINESSDIVISIONNAME"]))
            {
                sql.Append(" and BUSINESSDIVISIONNAME like '%" + Request.QueryString["BUSINESSDIVISIONNAME"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["BUSINESSDIVISIONCODE"]))
            {
                sql.Append(" and BUSINESSDIVISIONCODE like '%" + Request.QueryString["BUSINESSDIVISIONCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CONFIRMIDEA"]))
            {
                sql.Append(" and CONFIRMIDEA like '%" + Request.QueryString["CONFIRMIDEA"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SUPPLIERSTATE"]))
            {
                sql.Append(" and SUPPLIERSTATE like '%" + Request.QueryString["SUPPLIERSTATE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["ISALLARRIVE"]))
            {
                sql.Append(" and ISALLARRIVE like '%" + Request.QueryString["ISALLARRIVE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["OUTREGID"]))
            {
                sql.Append(" and OUTREGID = '" + Request.QueryString["OUTREGID"] + "'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["OUTREGCODE"]))
            {
                sql.Append(" and OUTREGCODE like '%" + Request.QueryString["OUTREGCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["OUTREGADDRESS"]))
            {
                sql.Append(" and OUTREGADDRESS like '%" + Request.QueryString["OUTREGADDRESS"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["FAULTREASONID"]))
            {
                sql.Append(" and FAULTREASONID = '" + Request.QueryString["FAULTREASONID"] + "'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["FAULTREASONCODE"]))
            {
                sql.Append(" and FAULTREASONCODE like '%" + Request.QueryString["FAULTREASONCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["FAULTREASONNAME"]))
            {
                sql.Append(" and FAULTREASONNAME like '%" + Request.QueryString["FAULTREASONNAME"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SERVICECARDTYPE"]))
            {
                sql.Append(" and SERVICECARDTYPE like '%" + Request.QueryString["SERVICECARDTYPE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SERVICECARDTYPENAME"]))
            {
                sql.Append(" and SERVICECARDTYPENAME like '%" + Request.QueryString["SERVICECARDTYPENAME"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SERVICEPLOYID"]))
            {
                sql.Append(" and SERVICEPLOYID = '" + Request.QueryString["SERVICEPLOYID"] + "'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SERVICEPLOYCODE"]))
            {
                sql.Append(" and SERVICEPLOYCODE like '%" + Request.QueryString["SERVICEPLOYCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SPDISTANCE"]))
            {
                sql.Append(" and SPDISTANCE like '%" + Request.QueryString["SPDISTANCE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["WORKINFO"]))
            {
                sql.Append(" and WORKINFO like '%" + Request.QueryString["WORKINFO"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["TELFEE"]))
            {
                sql.Append(" and TELFEE like '%" + Request.QueryString["TELFEE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SYSWORKFEE"]))
            {
                sql.Append(" and SYSWORKFEE like '%" + Request.QueryString["SYSWORKFEE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SYSMATFEE"]))
            {
                sql.Append(" and SYSMATFEE like '%" + Request.QueryString["SYSMATFEE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["ISALERT"]))
            {
                sql.Append(" and ISALERT like '%" + Request.QueryString["ISALERT"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CLAIMTEMPLETID"]))
            {
                sql.Append(" and CLAIMTEMPLETID = '" + Request.QueryString["CLAIMTEMPLETID"] + "'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CLAIMTEMPLETCODE"]))
            {
                sql.Append(" and CLAIMTEMPLETCODE like '%" + Request.QueryString["CLAIMTEMPLETCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["KIND"]))
            {
                sql.Append(" and KIND like '%" + Request.QueryString["KIND"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SALEDATEBegin"]))
            {
                sql.Append(" and " + bll._dal.GetBeginDateString("SALEDATE", Request.QueryString["SALEDATEBegin"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SALEDATEEnd"]))
            {
                sql.Append(" and " + bll._dal.GetEndDateString("SALEDATE", Request.QueryString["SALEDATEEnd"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["MILEAGE"]))
            {
                sql.Append(" and MILEAGE like '%" + Request.QueryString["MILEAGE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["WORKTIME"]))
            {
                sql.Append(" and WORKTIME like '%" + Request.QueryString["WORKTIME"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["STATIONCACUSTATUS"]))
            {
                sql.Append(" and STATIONCACUSTATUS like '%" + Request.QueryString["STATIONCACUSTATUS"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SALETIMELASTING"]))
            {
                sql.Append(" and SALETIMELASTING like '%" + Request.QueryString["SALETIMELASTING"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["DUTYCACUSTATUS"]))
            {
                sql.Append(" and DUTYCACUSTATUS like '%" + Request.QueryString["DUTYCACUSTATUS"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["FINISHTIMEBegin"]))
            {
                sql.Append(" and " + bll._dal.GetBeginDateString("FINISHTIME", Request.QueryString["FINISHTIMEBegin"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["FINISHTIMEEnd"]))
            {
                sql.Append(" and " + bll._dal.GetEndDateString("FINISHTIME", Request.QueryString["FINISHTIMEEnd"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["FINISHNAME"]))
            {
                sql.Append(" and FINISHNAME like '%" + Request.QueryString["FINISHNAME"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["FINISHID"]))
            {
                sql.Append(" and FINISHID = '" + Request.QueryString["FINISHID"] + "'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["STATIONCODE"]))
            {
                sql.Append(" and STATIONCODE like '%" + Request.QueryString["STATIONCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["STATIONNAME"]))
            {
                sql.Append(" and STATIONNAME like '%" + Request.QueryString["STATIONNAME"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["STATUSLOG"]))
            {
                sql.Append(" and STATUSLOG like '%" + Request.QueryString["STATUSLOG"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["FAULTDESCRIPTION"]))
            {
                sql.Append(" and FAULTDESCRIPTION like '%" + Request.QueryString["FAULTDESCRIPTION"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["REPDATEBegin"]))
            {
                sql.Append(" and " + bll._dal.GetBeginDateString("REPDATE", Request.QueryString["REPDATEBegin"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["REPDATEEnd"]))
            {
                sql.Append(" and " + bll._dal.GetEndDateString("REPDATE", Request.QueryString["REPDATEEnd"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["DEALOPINION"]))
            {
                sql.Append(" and DEALOPINION like '%" + Request.QueryString["DEALOPINION"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["LINKERNAME"]))
            {
                sql.Append(" and LINKERNAME like '%" + Request.QueryString["LINKERNAME"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["LINKERTEL"]))
            {
                sql.Append(" and LINKERTEL like '%" + Request.QueryString["LINKERTEL"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["QUALITYID"]))
            {
                sql.Append(" and QUALITYID = '" + Request.QueryString["QUALITYID"] + "'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["QUALITYCODE"]))
            {
                sql.Append(" and QUALITYCODE like '%" + Request.QueryString["QUALITYCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["VEHICLETYPECLASS"]))
            {
                sql.Append(" and VEHICLETYPECLASS like '%" + Request.QueryString["VEHICLETYPECLASS"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["STRONGPREMIUM"]))
            {
                sql.Append(" and STRONGPREMIUM like '%" + Request.QueryString["STRONGPREMIUM"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["ISEXCEEDWARRANTY"]))
            {
                sql.Append(" and ISEXCEEDWARRANTY like '%" + Request.QueryString["ISEXCEEDWARRANTY"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["ISFEEDBACK"]))
            {
                sql.Append(" and ISFEEDBACK like '%" + Request.QueryString["ISFEEDBACK"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["FEEDBACKIDEA"]))
            {
                sql.Append(" and FEEDBACKIDEA like '%" + Request.QueryString["FEEDBACKIDEA"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["FEEDBACKDATEBegin"]))
            {
                sql.Append(" and " + bll._dal.GetBeginDateString("FEEDBACKDATE", Request.QueryString["FEEDBACKDATEBegin"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["FEEDBACKDATEEnd"]))
            {
                sql.Append(" and " + bll._dal.GetEndDateString("FEEDBACKDATE", Request.QueryString["FEEDBACKDATEEnd"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["PRODUCTSATISFACTION"]))
            {
                sql.Append(" and PRODUCTSATISFACTION like '%" + Request.QueryString["PRODUCTSATISFACTION"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SERVICESATISFACTION"]))
            {
                sql.Append(" and SERVICESATISFACTION like '%" + Request.QueryString["SERVICESATISFACTION"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SATISFIEDREASONS"]))
            {
                sql.Append(" and SATISFIEDREASONS like '%" + Request.QueryString["SATISFIEDREASONS"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["LASTVIEWDATEBegin"]))
            {
                sql.Append(" and LASTVIEWDATE >= '" + Request.QueryString["LASTVIEWDATEBegin"].Trim() + "'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["LASTVIEWDATEEnd"]))
            {
                sql.Append(" and LASTVIEWDATE < '" + Request.QueryString["LASTVIEWDATEEnd"].Trim() + "'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["ASSIGNEDPERSONS"]))
            {
                sql.Append(" and ASSIGNEDPERSONS like '%" + Request.QueryString["ASSIGNEDPERSONS"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["ASSIGNEDPERSONNAME"]))
            {
                sql.Append(" and ASSIGNEDPERSONNAME like '%" + Request.QueryString["ASSIGNEDPERSONNAME"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["DISTRIBUTIONPEOPLE"]))
            {
                sql.Append(" and DISTRIBUTIONPEOPLE like '%" + Request.QueryString["DISTRIBUTIONPEOPLE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["DISTRIBUTIONPEOPLENAME"]))
            {
                sql.Append(" and DISTRIBUTIONPEOPLENAME like '%" + Request.QueryString["DISTRIBUTIONPEOPLENAME"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["ALLOCATEDTIMEBegin"]))
            {
                sql.Append(" and " + bll._dal.GetBeginDateString("ALLOCATEDTIME", Request.QueryString["ALLOCATEDTIMEBegin"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["ALLOCATEDTIMEEnd"]))
            {
                sql.Append(" and " + bll._dal.GetEndDateString("ALLOCATEDTIME", Request.QueryString["ALLOCATEDTIMEEnd"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["LIMITED"]))
            {
                sql.Append(" and LIMITED like '%" + Request.QueryString["LIMITED"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["FEEDBACKNUMBER"]))
            {
                sql.Append(" and FEEDBACKNUMBER like '%" + Request.QueryString["FEEDBACKNUMBER"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["ISSERVICECARD"]))
            {
                sql.Append(" and ISSERVICECARD like '%" + Request.QueryString["ISSERVICECARD"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["MARKETDEPARTMENTID"]))
            {
                sql.Append(" and MARKETDEPARTMENTID = '" + Request.QueryString["MARKETDEPARTMENTID"] + "'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["MARKETDEPARTMENTCODE"]))
            {
                sql.Append(" and MARKETDEPARTMENTCODE like '%" + Request.QueryString["MARKETDEPARTMENTCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["MARKETDEPARTMENTNAME"]))
            {
                sql.Append(" and MARKETDEPARTMENTNAME like '%" + Request.QueryString["MARKETDEPARTMENTNAME"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["DEALERNAME"]))
            {
                sql.Append(" and DEALERNAME like '%" + Request.QueryString["DEALERNAME"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["DEALERCODE"]))
            {
                sql.Append(" and DEALERCODE like '%" + Request.QueryString["DEALERCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["PRODUCTCODE"]))
            {
                sql.Append(" and PRODUCTCODE like '%" + Request.QueryString["PRODUCTCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["ENGINEFACTORY"]))
            {
                sql.Append(" and ENGINEFACTORY like '%" + Request.QueryString["ENGINEFACTORY"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["ENGINETYPE"]))
            {
                sql.Append(" and ENGINETYPE like '%" + Request.QueryString["ENGINETYPE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["ENGINECODE"]))
            {
                sql.Append(" and ENGINECODE like '%" + Request.QueryString["ENGINECODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["REPWORKERNAME"]))
            {
                sql.Append(" and REPWORKERNAME like '%" + Request.QueryString["REPWORKERNAME"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["REPWORKERTEL"]))
            {
                sql.Append(" and REPWORKERTEL like '%" + Request.QueryString["REPWORKERTEL"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["STPRODUCTSERIAL"]))
            {
                sql.Append(" and STPRODUCTSERIAL like '%" + Request.QueryString["STPRODUCTSERIAL"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["AREAWORKFEE"]))
            {
                sql.Append(" and AREAWORKFEE like '%" + Request.QueryString["AREAWORKFEE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SENDCODE"]))
            {
                sql.Append(" and SENDCODE like '%" + Request.QueryString["SENDCODE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["OUTTYPE"]))
            {
                sql.Append(" and OUTTYPE like '%" + Request.QueryString["OUTTYPE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["LEAVEFACTORYTYPEBegin"]))
            {
                sql.Append(" and " + bll._dal.GetBeginDateString("LEAVEFACTORYTYPE", Request.QueryString["LEAVEFACTORYTYPEBegin"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["LEAVEFACTORYTYPEEnd"]))
            {
                sql.Append(" and " + bll._dal.GetEndDateString("LEAVEFACTORYTYPE", Request.QueryString["LEAVEFACTORYTYPEEnd"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SUBREPTIMEBegin"]))
            {
                sql.Append(" and " + bll._dal.GetBeginDateString("SUBREPTIME", Request.QueryString["SUBREPTIMEBegin"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SUBREPTIMEEnd"]))
            {
                sql.Append(" and " + bll._dal.GetEndDateString("SUBREPTIME", Request.QueryString["SUBREPTIMEEnd"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["CUSTOMERADDRESS"]))
            {
                sql.Append(" and CUSTOMERADDRESS like '%" + Request.QueryString["CUSTOMERADDRESS"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["PRODUCTTYPE"]))
            {
                sql.Append(" and PRODUCTTYPE like '%" + Request.QueryString["PRODUCTTYPE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SYSOUTFEE"]))
            {
                sql.Append(" and SYSOUTFEE like '%" + Request.QueryString["SYSOUTFEE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SYSOTHERCLAIM"]))
            {
                sql.Append(" and SYSOTHERCLAIM like '%" + Request.QueryString["SYSOTHERCLAIM"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SYSAREAWORKFEE"]))
            {
                sql.Append(" and SYSAREAWORKFEE like '%" + Request.QueryString["SYSAREAWORKFEE"] + "%'");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SUBMITDATEBegin"]))
            {
                sql.Append(" and " + bll._dal.GetBeginDateString("SUBMITDATE", Request.QueryString["SUBMITDATEBegin"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SUBMITDATEEnd"]))
            {
                sql.Append(" and " + bll._dal.GetEndDateString("SUBMITDATE", Request.QueryString["SUBMITDATEEnd"].Trim()) + " ");
            }
            if (!String.IsNullOrEmpty(Request.QueryString["SUBMITPERSON"]))
            {
                sql.Append(" and SUBMITPERSON like '%" + Request.QueryString["SUBMITPERSON"] + "%'");
            }

            if (!UserLoginInfo.IsAdministrator())
            {
                sql.Append(" and BUSINESSDIVISIONCODE = '" + _userLoginInfo.UserEntity.BUSINESSDIVISIONCODE.Trim() + "'");
                //if (PageHelper.GetQueryString(this.Page, "SearchType") != "VehicleAssociate")
                //{
                //    //sql.Append(caBll.GenerateContentAuthorityConditions(_userLoginInfo, "ASSIGNEDPERSONS"));
                //}
            }
            return sql;

        }

        /// <summary>
        /// 页面数据绑定
        /// </summary>
        private void gvDataBinding()
        {
            #region 查询条件字符串
            StringBuilder sql = GenerationSQLString();
            #endregion

            List<T_CLAIMFORM_Entity> list;

            //获取总的记录条数
            gvList.RecordCount = (int)bll.GetCount(sql.ToString());

            list = bll.GetList(sql.ToString(), gvList.CurrentPageIndex * gvList.PageSize, gvList.PageSize, gvList.SortConditions);

            gvList.DataSource = list;
            gvList.DataKeyNames = new string[] { "CLAIMFORMID" };
            gvList.DataBind();

        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string url = HttpContext.Current.Request.Url.AbsolutePath;
            PageHelper.GetControlToUrlQuery(this.Page, ref url);
            Response.Redirect(url);
        }


        protected void btnExportExcel_Click(object sender, EventArgs e)
        {
            if (UserLoginInfo.IsAdministrator())
            {
                PageHelper.ShowMessage(this.Page, "请不要用系统管理导出数据！");
                return;
            }

            int recordBegin = StringHelper.ToInt(txtRecordBegin.Text.Trim(), 0);
            if (recordBegin != 0)
            {
                recordBegin--;
            }
            int recordEnd = StringHelper.ToInt(txtRecordEnd.Text.Trim(), 0);
            if (recordEnd != 0)
            {
                recordEnd--;
            }
            int recordCount = recordEnd - recordBegin;
            if (recordCount >= StringHelper.ToInt(configBll.GetCacheValueByName(this.Page, "ExportMaxRows"), 10000))
            {
                PageHelper.ShowMessage("导出区间大于单次导出数！");
                return;
            }

            StringBuilder sql = GenerationSQLString();
            DataTable dataTable = bll.GetDataTable(sql.ToString(), recordBegin, recordCount, gvList.SortConditions);
            //StringBuilder sql = GenerationSQLString();
            //DataTable dataTable = bll.GetDataTable(sql.ToString(), gvList.SortConditions);

            List<NPOIExcelHelper.FieldInfo> fieldInfos = new List<NPOIExcelHelper.FieldInfo>();

            #region 导出数据列

            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CLAIMFORMID", "索赔单编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CASEID", "工单编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("OBJID", "原系统编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CODE", "编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CORPCODE", "企业编码"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CORPNAME", "企业名称"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("STATUS", "记录状态"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CREATETIME", "创建时间"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CREATEPEOPLEID", "创建人编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CREATEPEOPLE", "创建人"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("LASTMODIFYPEOPLEID", "最后修改人编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("LASTMODIFYPEOPLE", "最后修改人"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("LASTMODIFYTIME", "最后修改时间"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("REMARK", "备注"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("BRANDCODE", "品牌编码"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("BRANDNAME", "品牌名称"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("VINCODE", "VIN码"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CUSTOMERID", "客户编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CUSTOMERCODE", "客户代码"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CUSTOMERNAME", "客户姓名"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CUSTOMERTEL", "客户电话"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("MOBILEPHONE", "手机"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("HOMEPHONE", "家庭电话"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("DUTYCORPCODE", "责任供应商编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("DUTYCORPNAME", "责任供应商名称"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CAUSEMATERIALNAME", "主因旧件名称"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CAUSEMATERIALCODE", "主因旧件编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("EXAMIDEA", "服务科审核意见"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("OTHERCLAIM", "其他索赔费用"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("OTHERCLAIMREASON", "其他索赔费用原因"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("OTHERSPAREPRICE", "外购件金额合计"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("WORKFEE", "工时费"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("MATFEE", "材料费"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("OUTFEE", "外出费用"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("TOTALFEE", "费用合计"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("MANAGEFEE", "配件管理费合计"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("JUDGERESULT", "保修判断结果"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("APPLYREPORTID", "申请单ID"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("APPLYREPORTCODE", "申请单编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("APPLYREPORTTYPE", "申请单类型"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("ORIGINALTOTALFEE", "原始索赔费用合计"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SPTYPE", "索赔类型"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("ISREPEATREPAIR", "是否重复维修"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("BUSINESSDIVISIONID", "事业部编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("BUSINESSDIVISIONNAME", "事业部名称"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("BUSINESSDIVISIONCODE", "事业部代码"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CONFIRMIDEA", "确认意见"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SUPPLIERSTATE", "供应商确认状态"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("ISALLARRIVE", "旧件处理状态"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("OUTREGID", "外出登记ID"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("OUTREGCODE", "外出登记单编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("OUTREGADDRESS", "外出地点"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("FAULTREASONID", "故障原因ID"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("FAULTREASONCODE", "故障原因编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("FAULTREASONNAME", "故障原因名称"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SERVICECARDTYPE", "索赔单类型"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SERVICECARDTYPENAME", "索赔单类型名"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SERVICEPLOYID", "服务活动ID"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SERVICEPLOYCODE", "服务活动编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SPDISTANCE", "服务商距离"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("WORKINFO", "作业工况"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("TELFEE", "通讯费"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SYSWORKFEE", "系统工时费"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SYSMATFEE", "系统材料费"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("ISALERT", "是否超出预警"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CLAIMTEMPLETID", "索赔模版ID"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CLAIMTEMPLETCODE", "索赔模版编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("KIND", "索赔类型2"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SALEDATE", "销售时间"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("MILEAGE", "里程"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("WORKTIME", "工作时间"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("STATIONCACUSTATUS", "结算状态(服务站)"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SALETIMELASTING", "售出时长"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("DUTYCACUSTATUS", "结算状态(责任供应商)"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("FINISHTIME", "审核时间"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("FINISHNAME", "审核人"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("FINISHID", "审核人ID"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("STATIONCODE", "服务站编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("STATIONNAME", "服务站名称"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("STATUSLOG", "记录状态变更日志"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("FAULTDESCRIPTION", "故障描述"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("REPDATE", "维修时间"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("DEALOPINION", "处理意见或措施"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("LINKERNAME", "联系人名称"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("LINKERTEL", "联系人电话"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("QUALITYID", "质量反馈单ID"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("QUALITYCODE", "质量反馈单号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("VEHICLETYPECLASS", "车辆属性"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("STRONGPREMIUM", "强保费"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("ISEXCEEDWARRANTY", "是否超保"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("ISFEEDBACK", "是否已回访"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("FEEDBACKNUMBER", "回访次数"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("FEEDBACKIDEA", "回访意见"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("FEEDBACKDATE", "回访时间"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("PRODUCTSATISFACTION", "产品满意度"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SERVICESATISFACTION", "服务满意度"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SATISFIEDREASONS", "不满意原因"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("LASTVIEWDATE", "最后查看时间"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("ASSIGNEDPERSONS", "被分配人"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("ASSIGNEDPERSONNAME", "被分配人名"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("DISTRIBUTIONPEOPLE", "分配人"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("DISTRIBUTIONPEOPLENAME", "分配人名"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("ALLOCATEDTIME", "分配时间"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("LIMITED", "时限"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("ISSERVICECARD", "服务监督卡"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("MARKETDEPARTMENTID", "市场部编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("MARKETDEPARTMENTCODE", "市场部代码"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("MARKETDEPARTMENTNAME", "市场部名称"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("DEALERNAME", "经销商名称"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("DEALERCODE", "经销商代码"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("PRODUCTCODE", "产品编号"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("ENGINEFACTORY", "发动机厂"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("ENGINETYPE", "发动机类型"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("ENGINECODE", "发动机代码"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("REPWORKERNAME", "维修技工名称"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("REPWORKERTEL", "维修工人电话"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("STPRODUCTSERIAL", "产品序列"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("AREAWORKFEE", "地区工费"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SENDCODE", "发送代码"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("OUTTYPE", "外出方式"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("LEAVEFACTORYTYPE", "出厂时间"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SUBREPTIME", "报修时间"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("CUSTOMERADDRESS", "客户地址"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("PRODUCTTYPE", "产品类型"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SYSOUTFEE", "系统外出费用"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SYSOTHERCLAIM", "系统其它索赔"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SYSAREAWORKFEE", "系统跨区工作费"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SUBMITDATE", "提交日期"));
            fieldInfos.Add(new NPOIExcelHelper.FieldInfo("SUBMITPERSON", "提交人"));

            #endregion

            NPOIExcelHelper.DataTableToExcel(dataTable, fieldInfos, "claimform.xls");
            dataTable.Clear();
            dataTable = null;
            GC.Collect();
        }

        /// <summary>
        /// Handles the Click event of the btnBatchPass control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnBatchPass_Click(object sender, EventArgs e)
        {
            T_CLAIMFORMRESULT_Entity cfrEntity;
            List<T_CLAIMFORM_Entity> list = GetSelected(gvList);

            foreach (var claimformEntity in list)
            {
                try
                {
                    if (claimformEntity.ISFEEDBACK.ToString() != ((int)IsFeedBack.已回访).ToString())
                    {
                        claimformEntity.ISFEEDBACK = (int) IsFeedBack.已回访;
                        claimformEntity.FEEDBACKDATE = DateTime.Now;
                        claimformEntity.STATUS = (int) ClaimStatus.回访审核通过;
                        claimformEntity.ASSIGNEDPERSONNAME = _userLoginInfo.UserEntity.USERNAME;
                        claimformEntity.FEEDBACKIDEA = "批量通过";
                        //cfrEntity = new T_CLAIMFORMRESULT_Entity();
                        //cfrEntity.BUSINESSDIVISIONCODE = _userLoginInfo.UserEntity.BUSINESSDIVISIONCODE;
                        //cfrEntity.BUSINESSDIVISIONID = _userLoginInfo.UserEntity.BUSINESSDIVISIONID;
                        //cfrEntity.BUSINESSDIVISIONNAME = _userLoginInfo.UserEntity.BUSINESSDIVISIONNAME;
                        //cfrEntity.CLAIMFROMOBJID = claimformEntity.OBJID;
                        //cfrEntity.CLAIMFROMID = claimformEntity.CLAIMFORMID;
                        //cfrEntity.CREATEPEOPLE = _userLoginInfo.UserEntity.CREATEPEOPLE;
                        //cfrEntity.CREATEPEOPLEID = _userLoginInfo.UserEntity.CREATEPEOPLEID;
                        //cfrEntity.CREATETIME = DateTime.Now;
                        //cfrEntity.FEEDBACKDATE = DateTime.Now;
                        //cfrEntity.FTIMESTAMP = DateTime.Now;
                        //cfrEntity.STATUS = ((int) ClaimStatus.回访审核通过).ToString();
                        //cfrEntity.FEEDBACKIDEA = "批量通过";
                        //claimFormResultBll.Insert(cfrEntity);
                        bll.Update(claimformEntity);
                        #region 回写VEI中间表索赔单
                        if (claimformEntity.BUSINESSDIVISIONCODE == "8101")//农装
                        {
                            NZ_TCLAIMCARD_Entity nzclaimform = new NZ_TCLAIMCARD_Entity();
                            nzclaimform = _nzclaimform.GetEntity("OBJID", claimformEntity.OBJID);
                            if (nzclaimform != null)
                            {
                                nzclaimform.ISFEEDBACK = (int)claimformEntity.ISFEEDBACK;
                                nzclaimform.STATUS = (int)claimformEntity.STATUS;
                                nzclaimform.FEEDBACKIDEA = claimformEntity.FEEDBACKIDEA;
                                nzclaimform.PRODUCTSATISFACTION = claimformEntity.PRODUCTSATISFACTION == "" ? 0 : int.Parse(claimformEntity.PRODUCTSATISFACTION);
                                nzclaimform.SERVICESATISFACTION = claimformEntity.SERVICESATISFACTION == "" ? 0 : int.Parse(claimformEntity.SERVICESATISFACTION); 
                                nzclaimform.NONESATISFACTION = claimformEntity.SATISFIEDREASONS;
                                nzclaimform.CC_UPDATE = 1;
                                _nzclaimform.Update(nzclaimform);
                            }
                        }
                        else if (claimformEntity.BUSINESSDIVISIONCODE == "8106")//挖掘机
                        {
                            WJJ_TCLAIMCARD_Entity wjjclaimform = new WJJ_TCLAIMCARD_Entity();
                            wjjclaimform = _wjjclaimform.GetEntity("OBJID", claimformEntity.OBJID);
                            if (wjjclaimform != null)
                            {
                                wjjclaimform.ISFEEDBACK = (int)claimformEntity.ISFEEDBACK;
                                wjjclaimform.STATUS = (int)claimformEntity.STATUS;
                                wjjclaimform.FEEDBACKIDEA = claimformEntity.FEEDBACKIDEA;
                                wjjclaimform.CC_UPDATE = 1;
                                _wjjclaimform.Update(wjjclaimform);
                            }
                        }
                        else if (claimformEntity.BUSINESSDIVISIONCODE == "8102")//装载机
                        {
                            ZZJ_TCLAIMCARD_Entity zzjclaimform = new ZZJ_TCLAIMCARD_Entity();
                            zzjclaimform = _zzjclaimform.GetEntity("OBJID", claimformEntity.OBJID);
                            if (zzjclaimform != null)
                            {
                                zzjclaimform.ISFEEDBACK = (int)claimformEntity.ISFEEDBACK;
                                zzjclaimform.STATUS = (int)claimformEntity.STATUS;
                                zzjclaimform.FEEDBACKIDEA = claimformEntity.FEEDBACKIDEA;
                                zzjclaimform.CC_UPDATE = 1;
                                _zzjclaimform.Update(zzjclaimform);
                            }
                        }
                        else if (claimformEntity.BUSINESSDIVISIONCODE == "8103")//五星汽车
                        {
                            QC_TCLAIMCARD_Entity qcclaimform = new QC_TCLAIMCARD_Entity();
                            qcclaimform = _qcclaimform.GetEntity("OBJID", claimformEntity.OBJID);
                            if (qcclaimform != null)
                            {
                                qcclaimform.ISFEEDBACK = (int)claimformEntity.ISFEEDBACK;
                                qcclaimform.STATUS = (int)claimformEntity.STATUS;
                                qcclaimform.ISREVIEW = (int)claimformEntity.ISFEEDBACK;
                                qcclaimform.REVIEWREMARK = claimformEntity.FEEDBACKIDEA;
                                qcclaimform.REVIEWTIME = claimformEntity.FEEDBACKDATE;
                                qcclaimform.CC_UPDATE = 1;
                                _qcclaimform.Update(qcclaimform);
                            }
                        }
                        else if (claimformEntity.BUSINESSDIVISIONCODE == "8104")//五星摩托
                        {
                            MT_TCLAIMCARD_Entity mtclaimform = new MT_TCLAIMCARD_Entity();
                            mtclaimform = _mtclaimform.GetEntity("OBJID", claimformEntity.OBJID);
                            if (mtclaimform != null)
                            {
                                mtclaimform.ISFEEDBACK = (int)claimformEntity.ISFEEDBACK;
                                mtclaimform.STATUS = (int)claimformEntity.STATUS;
                                mtclaimform.ISREVIEW = (int)claimformEntity.ISFEEDBACK;
                                mtclaimform.REVIEWREMARK = claimformEntity.FEEDBACKIDEA;
                                mtclaimform.CC_UPDATE = 1;
                                _mtclaimform.Update(mtclaimform);
                            }
                        }
                        #endregion

                    }
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog("Log_DP_ClaimFrom",
                                                      ex.Message + "\r\nCLAIMFORMID:" + claimformEntity.CLAIMFORMID);
                }
            }

            PageHelper.ShowMessage(this.Page, "批量审批通过完成！", true);


            //string url = HttpContext.Current.Request.Url.AbsolutePath;
            //PageHelper.GetControlToUrlQuery(this.Page, ref url);
            //Response.Redirect(url);
        }


        /// <summary>
        /// Gets the selected.
        /// </summary>
        /// <param name="gv">The gv.</param>
        /// <returns></returns>
        private List<T_CLAIMFORM_Entity> GetSelected(GridView gv)
        {
            T_CLAIMFORM_Entity claimFormEntity;
            List<T_CLAIMFORM_Entity> list = new List<T_CLAIMFORM_Entity>();
            if (gv == null) return list;
            CheckBox cb;
            foreach (GridViewRow gvr in gv.Rows)
            {
                cb = gvr.FindControl("cbItem") as CheckBox;
                if (cb == null) continue;
                if (!cb.Checked) continue;
                claimFormEntity = bll.GetEntity("CLAIMFORMID", gv.DataKeys[gvr.RowIndex].Values["CLAIMFORMID"].ToString());
                if (claimFormEntity != null)
                {
                    list.Add(claimFormEntity);
                }
            }
            return list;
        }


        #region GridView 事件
        /// <summary>
        /// GridView 删除事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            T_CLAIMFORM_Entity entity = new T_CLAIMFORM_Entity();
            entity.CLAIMFORMID = StringHelper.ToLong((sender as GridView).DataKeys[e.RowIndex].Values[0].ToString());

            long rel = bll.Delete(entity);
            if (rel > 0)
            {
                Response.Redirect(HttpContext.Current.Request.RawUrl);
            }
            else
            {

            }

        }

        /// <summary>
        /// GridView 行数据绑定事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            string temp;
            switch (e.Row.RowType)
            {
                case DataControlRowType.DataRow:
                    {
                        GridView gv = (sender as GridView);
                        for (int i = 0; i < gv.Columns.Count; i++)
                        {
                            TemplateField tf = gv.Columns[i] as TemplateField;
                            if (tf != null)
                            {
                                #region 存储值 转换成  显示值
                                switch (tf.HeaderText)
                                {
                                    case "操作":
                                        {
                                            if (PageHelper.GetQueryString(this.Page, "SearchType") == "VehicleAssociate")
                                            {
                                                e.Row.Cells[i].Controls.Clear();
                                            }
                                            e.Row.Cells[i].Attributes.Add("style", "white-space: nowrap;");
                                        }
                                        break;
                                    default:
                                        {
                                            e.Row.Cells[i].Attributes.Add("style", "white-space: nowrap;");
                                        }
                                        break;

                                }
                                #endregion
                            }

                            BoundField bf = gv.Columns[i] as BoundField;
                            if (bf != null)
                            {
                                #region 存储值 转换成  显示值
                                switch (bf.DataField)
                                {
                                    case "PRODUCTSATISFACTION":
                                        {
                                            try
                                            {
                                                temp = e.Row.Cells[i].Text.Trim();
                                                temp = dBll.GetCacheValueByTypeKey(this.Page, "ClaimFormProductSatisfaction", temp);
                                                e.Row.Cells[i].Text = temp;
                                            }
                                            catch (Exception)
                                            {

                                                //throw;
                                            }
                                        }
                                        break;
                                    case "SERVICESATISFACTION":
                                        {
                                            try
                                            {
                                                temp = e.Row.Cells[i].Text.Trim();
                                                temp = dBll.GetCacheValueByTypeKey(this.Page, "ClaimFormServiceSatisfaction", temp);
                                                e.Row.Cells[i].Text = temp;
                                            }
                                            catch (Exception)
                                            {

                                                //throw;
                                            }
                                        }
                                        break;
                                    case "ISFEEDBACK":
                                        {
                                            temp = e.Row.Cells[i].Text.Trim();
                                            temp = ((IsFeedBack)Enum.Parse(typeof(IsFeedBack), temp)).ToString();
                                            e.Row.Cells[i].Text = temp;
                                        }
                                        break;
                                    case "STATUS":
                                        {
                                            temp = e.Row.Cells[i].Text.Trim();
                                            temp = ((ClaimStatus)Enum.Parse(typeof(ClaimStatus), temp)).ToString();
                                            e.Row.Cells[i].Text = temp;
                                        }
                                        break;
                                    default:
                                        {

                                        }
                                        break;
                                }
                                #endregion
                            }
                        }
                    }
                    break;
                case DataControlRowType.Header:
                    {

                    }
                    break;
                case DataControlRowType.Pager:
                    {

                    }
                    break;
                case DataControlRowType.EmptyDataRow:
                    {


                    }
                    break;
                default:

                    break;
            }

        }

        /// <summary>
        /// GridView 行创建事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvList_RowCreated(object sender, GridViewRowEventArgs e)
        {
            switch (e.Row.RowType)
            {
                case DataControlRowType.DataRow:
                    {

                    }
                    break;
                case DataControlRowType.Header:
                    {

                    }
                    break;
                case DataControlRowType.Pager:
                    {

                    }
                    break;
                case DataControlRowType.EmptyDataRow:
                    {


                    }
                    break;
                default:

                    break;
            }

        }
        #endregion
		
    }
}
